;;; -*- Mode:LISP; Syntax:Common-Lisp -*-
;;; copyright (c) 2014-2015 David D. McDonald  -- all rights reserved
;;;
;;;     File:  "ddm-workspace"
;;;   Module:  "init;workspaces:"
;;;  version:  August 2015

;; Initiated 10/9/14 for personalized settings and recording what I'm doing -- ddm.

(in-package :sparser)

(setq *do-anaphora* nil)
;; 8/22/15 data structure for history is in progress

#| 
Rebuild pass2 on DA patterns
  run-island-checks-pass-two  look-for-length-three-patterns

 dereference-DefNP  complete-edge/hugin
 add-subsuming-object-to-discourse-history

 (ddm-ws-ed "pronoun hacking.lisp")
handle-any-anaphora  find-best-recent  post-analysis-operations
condition-anaphor-edge  (there-are-pronouns)
 (setq *trace-instance-recording* t)

;; Save out clean copies of sentence runs
  with-total-quiet


(ddm-ws-ed "NoSpace hassles.lisp")
(ddm-no-spaces) (trace-ns-sequences) (trace-fsas);;pw's
(setq *work-on-ns-patterns* t)   setup-verb

(p "RAS-ASSP.") -- bio-entity => protein
make-protein-pair/convert-bio-entity convert-bio-entity-to-protein

assess-parenthesized-content pts span-parentheses 
do-paired-punctuation-interior parse-chunk-interior

(p "BLAST sequence similarity searching 
indicated that the Bam32 SH2 domain is most highly related (30–37% identity) 
to those of the adaptor protein Nck, PLCγ1, PI3K p85 subunit, and the 
protein tyrosine phosphatases SHP-1 and SHP-2.")
;; No edges at all over "SHP", so the lookup has to handle it.

 ;; In case something goes south with the new 'unknown word' handler
 (ddm-ed "analyzers/tokenizer/lookup2.lisp")
   (trace-morphology)
  find-word  make-word/all-properties/or-primed  

;; auto-expansion of "ablate"
  (p "Also, Chk2 −/− DT40 avian B lymphoma cells in which Chk2 was genetically 
ablated by gene targeting ( xref ) exhibited decreased prometaphase accumulation 
in the presence of nocodazole, but not taxol, compared with controls ( xref ).")
|#
; (test-range-of-June-articles from n)   (current-string)
; (revert-to-regular-break)  (revert-to-error-break)
; (compare-to-snapshots) (sentence-string (previous (sentence)))

; "co-ordinate" => coordinate
;  compose-salient-hyphenated-literals  resolve-hyphen-between-two-words
;  nospace-hyphen-specialist


#|  (p "RICTOR knockdown increased the number of apoptotic MCF7 cells
on β1 integrin ligands up to 2-fold after 24 h in serum-free conditions.
β1 integrin-stimulation induced phosphorylation of both AKT1 and AKT2
but markedly preferred AKT2.")
  Doesn't see the sentence start because that's a lowecase beta
  and as a result the process of the actual second sentence is
  messed up -- no-space and chunking are absent. Why I don't know.
      period-marks-sentence-end?
|#

(defun ddm-standard ()  ;;    (ddm-standard)
  (setup-bio) ;; load the bio model etc.
  (trace-lexicon-unpacking) ;(trace-morphology)
  (setq *check-forms* t) ;; allow rule filtering by schema patern
  (setq *report-form-check-blocks* nil)
  (setq *debug-pronouns* nil)
  (revert-to-regular-break)
;  (setq *work-on-ns-patterns* t) 
;  (trace-parse-edges) (trace-rule-source) 
;  (trace-scan-patterns) (trace-network) (trace-terminals-sweep)
;  (trace-island-driving)
  ;; (ddm-workset)
;  (ddm-ws-ed "NoSpace hassles.lisp")
;  (ddm-no-spaces)
;  (ddm-doc-methods)
;; (ddm-read-from-documents)
;; (load-ddm-ws)
;; (ddm-polyword-conundrum)
;  (ddm-ed "init/versions/v4.0/workspace/abbreviations.lisp")
  (ddm-ed "init/workspaces/ddm-workspace.lisp")
  (setq *diagnose-consp-referents* t)
  ;;     (setq *show-section-printouts* t)
  ;; (test-dec)  (dtst nil t) (reset-dectest)
  ;;(test-overnight) (test-erk) (test-aspp2)
  ;;(test-jan) = dry-run   (retest)
  ;; (hashtable-to-alist 
  ;;(test-load-test)
)

(defun ddm-workset ()
  (ddm-ed "tools/basics/clos-classes.lisp")
  (ddm-ed "objects/doc/content-methods.lisp")
  (ddm-ed "objects/doc/content.lisp")
  (ddm-ed "drivers/sources/document.lisp")
  (ddm-ed "analyzers/psp/edges/lattice-operations.lisp"))

;; !!! Semtree isn't walking down to report all the
;; content in e.g. (p "Ras bound to GTP binds to BRAF.")
;  post-analysis-operations  collect-model

; c3-grammar-module-choices
; location c3-location located-in

; Make seg printer context sensitive: print-words-between-segments
;; Would have timing. Needs debugging
; (load-and-run-june-article-number 12)

#|   (setq *work-on-ns-patterns* t)
   
 (d (rule-set-for (word-named "")))
 (setq *show-section-printouts* t)
 (setq *trace-instance-recording* t)
 ;; (p "Phosphorylation of MEK1 at Ser218 and Ser222 activates it.")
 (p "BRAF bound to Ras transphosphorylates itself at Thr598.")
 resolve-stranded-hyphen (mono-, -tagged)

;=== Finish routines in 
; (p "in EphB1-induced ERK activation.")

;; GFP becomes the head
(p "We have used a mouse embryo fibroblast ERK1-knock-out 
cell line expressing green fluorescent protein (GFP)-tagged ERK1 
to probe the spatio-temporal regulation of ERK1.")
 setup-acronym-for-bio-entity  acronym-is-alternative-for-name
 assess-parenthesized-content
 hide-parenthesis-edge-at-pos span-parentheses
 referent-of-parentheticial-expression

(p "We previously reported that oncogenic RAS requires CRAF 
but not BRAF to activate MEK (Dumaz et al., 2006) 
and consistent with this, BRAF is inactive 
in NRAS mutant cells (Figure 1E).")
|#
;  (p "c-Raf/ MAPK-mediated [6].")

; r3/trunk/corpus/Walter-July-articles

;; Runaway 7/28/15
#| (load-xml-to-doc-if-necessary)
   (populate-june-article 'PMC4007333)
 (setq p1 (cadr (children (setq results (nth 3 (children (setq abstract (car (children (setq article *)
"Atorvastatin inhibited endothelial cell apoptosis induced 
by 1 mmol/L Hcy in a dose-dependent manner and the maximal 
inhibitory effect was reached at 100 μmol/L. 
Atorvastatin (10 μmol/L) significantly suppressed 
Hcy (1 mmol/L for 30 min) induced ROS accumulation (3.17±0.33 
vs 4.34±0.31, P <0.05). 
Atorvastatin (10 μmol/L) also antagonized Hcy (1 mmol/L for 30 min) 
induced activation of NADPH oxidase (2.57±0.49 vs 3.33±0.6, P <0.05). 
Furthermore, atorvastatin inhibited Hcy-induced phosphorylation of 
p38 MAPK (1.7±0.1 vs 2.22±0.25, P <0.05), 
similar effects occurred with DPI, NAC and SB203580."

 (trace-pronouns)  
 (trace-discourse-structure)
 (setq *trace-instance-recording* t)

In article 2  "c-termini"
|#

; (ddm-load-article-2 t)
(defun ddm-load-article-2 (&optional do-not-read)
  (load-xml-to-doc-if-necessary)
  (let ((fn (intern (symbol-name '#:make-sparser-doc-structure)
                    (find-package :r3)))
        (quiet-fn (intern (symbol-name 'debug-off)
                          (find-package :r3))))
    (funcall quiet-fn)
    (let* ((doc-elements
            (funcall fn "3847091" :dir "/Users/ddm/ws/R3/r3/trunk/darpa/January5-TestMaterials"))
           (article (car doc-elements)))
      (setq *article* article)
      (sweep-document article)
      (read-epistemic-features article)
      (unless do-not-read
        (read-from-document article))
      article)))
#| (setq article *article*)
(setq a *)  
(setq results (third (children a)))
(setq s (third (children results)))
(setq p1 (second (children *)) p2 (third (children *)))
(setq string (content-string p2)) |#

(defun ddm-debug-ns () ; (ddm-debug-ns)
  (trace-ns-sequences)
  ;; (trace-scan-patterns)
  ;; (trace-terminals-sweep)
  ;; (trace-terminals-loop)
  ;; (trace-fsas)
  (setq *work-on-ns-patterns* t))
(defun ddm-debug-ns-off () ; (ddm-debug-ns-off)
  (untrace-ns-sequences)
  ;; (untrace-scan-patterns)
  ;; (untrace-terminals-sweep)
  ;; (untrace-terminals-loop)
  ;; (untrace-fsas)
  (setq *work-on-ns-patterns* nil))


(defun ddm-issue-records ()
  (ddm-ws-ed "discourse and surface strings.lisp")
  (ddm-ws-ed "DA data.lisp")
  (ddm-ws-ed "pronoun hacking.lisp")
  (ddm-ws-ed "Parsing ASPP2.lisp")
  (ddm-ws-ed "PW digit-fsa hassle.lisp")
  (ddm-ws-ed "Weird stuff 6-6-15.lisp")
  (ddm-ws-ed "20 articles error.lisp")
  (ddm-ws-ed "NoSpace hassles.lisp")
  (ddm-ws-ed "mUbRas issues March 2015.lisp")
  (ddm-ws-ed "Doc str hassles.lisp")
  (ddm-ws-ed "polyword hassles.lisp")
  (draft-doc-ed "navigating the no-space code.lisp")
  (ddm-r3-notes "ERK nuclear transport tasks.lisp")
  (ddm-r3-notes "Playing with Will's sentences.lisp"))
      
; (noun "C-RAF:B-RAF" :super heterodimer)
; (trace-parse-edges) ;; extend into march-back-from-the-right/segment
; meta-. parse-at-the-segment-level

; (create-reactome-kb) ;; makes the Krisp model
; (ddm-ed "grammar/model/sl/biology/reactome/RAF_MEK_ERK_simple.lisp")
; (d (reactome-entity    "BiochemicalReaction13" "Complex21"

;; (setq *scan-for-unsaturated-individuals* t)
; (figure-7)  (cells-defNP)  (p *brent-story*)
; dec #34 -- "an event"

;; mine and remove (ddm-ed "drivers/chart/psp/bio-entity-scan.lisp")
(defun ddm-bio ()
  (ddm-ed "grammar/model/sl/biology/mechanics.lisp")
  (ddm-ed "grammar/model/sl/biology/taxonomy.lisp")
  (ddm-ed "grammar/model/sl/biology/proteins.lisp")
  (ddm-ed "grammar/model/sl/biology/protein-families.lisp")
  (ddm-ed "grammar/model/sl/biology/new-RAS2-proteins.lisp")
  (ddm-ed "grammar/model/sl/biology/amino-acids.lisp")
  (ddm-ed "grammar/model/sl/biology/terms1.lisp")
  (ddm-ed "grammar/model/sl/biology/drugs.lisp")
  (ddm-ed "grammar/model/sl/biology/phenomena.lisp")
  (ddm-ed "grammar/model/sl/biology/verbs1.lisp")
  (ddm-ed "grammar/model/sl/biology/rhetoric.lisp")
  (ddm-ed "grammar/model/sl/biology/doc-structure.lisp")
  (ddm-ed "grammar/model/sl/biology/switches.lisp")
  (ddm-ed "grammar/model/sl/biology/rules.lisp")
  (ddm-ed "grammar/model/sl/biology/parse-biopax.lisp") ;; +R3
  (ddm-ed "grammar/model/sl/biology/find-extension.lisp") ;; +R3
  (ddm-ed "grammar/model/sl/biology/new-words.lisp")
  (ddm-ed "grammar/model/sl/biology/new-word-list.lisp"))
;;  molecules and NGkappB not loaded
;; cf. model/sl/NIH/site.lisp

(defun ddm-timing ()
  (ddm-ed "drivers/timing/calculation.lisp")
  (ddm-ed "drivers/timing/cases.lisp")
  (ddm-ed "drivers/chart/select2.lisp")) ;; example

(defun ddm-think-about-methods ()
  (ddm-ed "objects/model/categories/clos-backing.lisp"))

(defun ddm-doc-methods ()
  (ddm-ed "objects/doc/content-methods.lisp")
  (ddm-ed "objects/doc/content.lisp")
  (ddm-ed "objects/doc/object1.lisp")
  (ddm-ed "drivers/sources/document.lisp")
  (ddm-ed "interface/grammar/sweep.lisp")
  (ddm-ed "drivers/chart/psp/no-brackets-protocol1.lisp")
  )

(defun ddm-fix-parentheses ()
  (ddm-ed "model/core/names/parens-after-name.lisp")
)

(defun ddm-itype-p-of-what ()
  (ddm-ed "objects/model/lattice-points/operations1.lisp")
)

;; longer, shorter, big:  def-attribution

;; Fix capitalization of chunking (online and afterwards)
; display-bracketing
  
;; Why is the right position of a number sometimes nil?
;  digit-FSA  make-edge-over-digit-sequence

(defun ddm-alphabet ()
  (ddm-ed "analyzers/tokenizer/alphabet.lisp")
  (ddm-ed "grammar/rules/words/punctuation1.lisp")
  (ddm-ed "grammar/rules/words/punctuation-constants.lisp")
  (ddm-ed "objects/chart/words/punctuation.lisp")
  (ddm-ed "analyzers/psp/patterns/scan-gophers.lisp"))

(defun ddm-rhetoric ()
  (ddm-ed "grammar/model/sl/biology/rhetoric.lisp")
  (ddm-ed "objects/doc/rhetoric.lisp")
  (ddm-ed "drivers/sources/document.lisp"))
  ; post-analysis-operations

(defun ddm-new-info ()
  (ddm-ed "objects/doc/rhetoric.lisp") ;; for classes and methods
  (ddm-ed "grammar/model/sl/biology/rhetoric.lisp") ;; for data
  (ddm-ed "objects/doc/content.lisp") ;; basics for 'containers'
  (ddm-ed "objects/doc/content-methods.lisp") ;; container classes & methods, e.g. after-action
  (ddm-ed "objects/doc/object1.lisp") ;; the classes that define article structure
  (ddm-ed "drivers/sources/document.lisp") ;; the methods that operate on article structure and organize reading
  (ddm-ed "init/workspaces/Biology-workspace.lisp") ;; Illustrates the pipeline
  (ddm-ed "drivers/chart/psp/no-brackets-protocol1.lisp") ;; master driver for reading a sentence: see post-analysis-operations
  (ddm-ed "driver/action/object.lisp") ;; define-completion-action
  (ddm-ed "driver/actions/trigger2.lisp") ;; action checker
  (ddm-ed "driver/actions/hook1.lisp") ;; carry out
  (ddm-ed "analyzers/psp/complete/complete-HA3.lisp") ;; site of action
  (ddm-ed "objects/traces/completion.lisp"))
  

(defun ddm-new-parsing-ws ()
  (ddm-ed "drivers/chart/psp/no-brackets-protocol1.lisp")
  (ddm-ed "drivers/chart/psp/multi-scan.lisp")
  (ddm-ed "drivers/chart/psp/chunker1.lisp")
  (ddm-ed "drivers/chart/psp/pts5.lisp")
  (ddm-ed "drivers/chart/psp/march-seg5.lisp")
  (ddm-ed "analyzers/SDM&P/scan1.lisp")
  (ddm-ed "drivers/forest/new-forest-protocol.lisp")
  (ddm-ed "drivers/forest/sweep.lisp")
  (ddm-ed "analyzers/psp/check/multiply7.lisp")
  (ddm-ed "drivers/forest/island-driving.lisp")
  (ddm-ed "drivers/forest/pass1.lisp")
  (ddm-ed "drivers/forest/pass2.lisp")
  (ddm-ed "drivers/forest/forest-gophers.lisp")
  (ddm-ed "drivers/forest/parsing-containers.lisp")
  (ddm-ed "grammar/rules/syntax/categories.lisp")
  (ddm-ed "drivers/forest/sweep.lisp")
  (ddm-ed "grammar/rules/DM&P/period-hook.lisp")
  (ddm-ed "grammar/rules/syntax/syntactic-rules.lisp")
  (ddm-ed "grammar/rules/syntax/syntax-functions.lisp")
  (ddm-ed "objects/traces/psp1.lisp")
  (ddm-ed "objects/traces/DA.lisp")
  (ddm-ed "analyzers/psp/patterns/traces.lisp")
  (ddm-ed "objects/traces/scan-patterns.lisp")
  (ddm-ed "objects/traces/treetops.lisp"))


(defun ddm-polyword-conundrum ()
  (ddm-ed "objects/chart/words/polywords4.lisp")
  (ddm-ed "objects/chart/words/polyword-form2.lisp")
  (ddm-ed "objects/rules/cfr/polywords2.lisp")
  (ddm-ed "analyzers/FSA/words3.lisp") ;; coordinate w/ FSAs
  (ddm-ed "drivers/chart/psp/multi-scan.lisp")
  (ddm-ed "grammar/rules/FSAs/polywords5.lisp")
  (ddm-ed "objects/traces/FSA1.lisp"))

(defun ddm-maybe-spurious-rule-dupb ()
  (ddm-ed "objects/rules/cfr/multiplier3.lisp")
  (ddm-ed "objects/rules/cfr/construct1.lisp")
  (ddm-ed "objects/rules/cfr/duplicates.lisp")
  (ddm-ed "objects/rules/cfr/define5.lisp"))
; i/r/s-make-the-rule
  
(defun ddm-pending-notes ()
  (sparser-doc-ed "notes/note on anaphora.lisp")
  (sparser-doc-ed "notes/note on bio control structure.lisp")
  (sparser-doc-ed "notes/note on edges.lisp")
  (sparser-doc-ed "notes/note on switches.lisp")
  (sparser-doc-ed "notes/note on simpler shortcuts.lisp")
  (sparser-doc-ed "notes/note on traces.lisp")
  (sparser-doc-ed "notes/Note on what happens when Sparser loads.lisp")
  (draft-doc-ed "Notes for polywords.lisp")
)


;; local anaphora, getting categories right
; sentence-sweep-loop  decode-realization-parameter-list

;; Are we making the right references in the history?
;    decode-category-parameter-list decode-index-field

;; Sentence sweep (dies on 2d wrap)
;   sentence-sweep  extract-string-from-char-buffers 
;   *length-of-character-input-buffer*  -- goosed to 50k

; (setq *work-on-ns-patterns* t)


(defun ddm-read-from-documents ()
  (ddm-ed "objects/doc/object1.lisp")
  (ddm-ed "objects/doc/content-methods.lisp")
  (ddm-ed "drivers/sources/document.lisp")
  (ddm-ed "drivers/chart/psp/no-brackets-protocol1.lisp")
  (ddm-ed "init/workspaces/Biology-workspace.lisp"))

(defun ddm-note-doc-structure ()
  (ddm-ed "grammar/model/sl/biology/doc-structure.lisp")
  (ddm-ed "analyzers/SD&P/note-text-relations.lisp")
  (ddm-ed "analyzers/SD&P/text-relations.lisp")
  (ddm-ed "analyzers/SD&P/text-relation-class.lisp")
  (ddm-ed "objects/doc/content.lisp")
  (ddm-ed "drivers/forest/parsing-containers.lisp")
  (ddm-ed "object/doc/doc-stream.lisp")
  (ddm-ed "objects/doc/object1.lisp")  ;; document structure
  (ddm-ed "tools/basics/resource.lisp")  ;; auto recycling
  (ddm-ed "objects/doc/classes.lisp"))

(defun ddm-no-spaces ()
  (ddm-ed "analyzers/psp/patterns/loader.lisp")
  (ddm-ed "analyzers/psp/patterns/traces.lisp")
  (ddm-ed "drivers/chart/psp/multi-scan.lisp")
  (ddm-ed "analyzers/psp/patterns/scan-gophers.lisp")
  (ddm-ed "analyzers/psp/patterns/charaterize-words.lisp")
  (ddm-ed "analyzers/psp/patterns/colon-patterns.lisp")
  (ddm-ed "analyzers/psp/patterns/hyphen-patterns.lisp")
  (ddm-ed "analyzers/psp/patterns/edge-patterns.lisp")
  (ddm-ed "analyzers/psp/patterns/slash-patterns.lisp")
  (ddm-ed "analyzers/psp/patterns/pattern-gophers.lisp")
  (ddm-ed "analyzers/psp/patterns/patterns.lisp")
  (ddm-ed "analyzers/psp/patterns/character-specialists.lisp")
  ;; (ddm-ed "grammar/rules/syntax/categories.lisp")
  ;; (ddm-ed "grammar/rules/SDM&P/create-categories.lisp")
  (ddm-ed "grammar/rules/DA/nospace-categories.lisp")
  (ddm-ed "drivers/chart/psp/no-brackets-protocol1.lisp")
  (ddm-ed "analyzers/psp/patterns/uniform-scan1.lisp") ;; driver
)


(defun ddm-tense-neg ()
  (ddm-ed "grammar/rules/syntax/syntax-functions.lisp")
  (ddm-ed "grammar/rules/syntax/tense.lisp")
  (ddm-ed "grammar/rules/syntax/be.lisp")
  (ddm-ed "grammar/rules/syntax/have.lisp")  
  (ddm-ed "grammar/rules/syntax/modals.lisp")
  (ddm-ed "grammar/model/core/kinds/processes.lisp"))

(defun ddm-better-be+adj ()
  (ddm-ed "grammar/rules/tree-families/vp.lisp")
  (ddm-ed "grammar/rules/tree-families/copula-patterns.lisp")
  (ddm-ed "grammar/model/sl/biology/verbs1.lisp"))

(defun ddm-write-additional-realization ()
  (ddm-ed "grammar/rules/tree-families/shortcut-master2.lisp")
  (ddm-ed "objects/model/tree-families/rdata1.lisp"))

(defun ddm-trap-new-words-write-sentence ()
  (ddm-ed "interface/grammar/sweep.lisp")
  (ddm-ed "analyzers/char-level/display1.lisp")
  (ddm-ed "drivers/chart/psp/no-brackets-protocol.lisp"))

(defun ddm-generalize-test ()
  (ddm-ed "tools/basics/test-functions.lisp")
  (ddm-ed "analyzers/forst/treetops.lisp")
  (ddm-ed "drivers/chart/psp/no-bracket-protocol.lisp"))

(defun ddm-simpler-compiling ()
  (ed "/Users/ddm/sparser/README")
  (ed "/Users/ddm/sparser/load-nlp.lisp")
  (ddm-ed "init/everything.lisp")
  (ddm-ed "init/Lisp/lload.lisp")
  (ddm-ed "init/scripts/compile-everything.lisp"))

;; Is this ordered right, walking through the edges?
; (ddm-ed "analyzers/psp/check/one-many1.lisp)

; (trace-paragraphs) ;; for sentences and periods
; (trace-edges) ;; edge over period as a literal?
; (trace-island-driving)  (untrace-island-driving) 
; (progn (trace-chunker) (trace-segments))
; (trace-terminals-sweep) ;; pw, etc.
; (progn (untrace-chunker) (untrace-segments) (untrace-terminals-sweep)  (untrace-island-driving))

; exploded-tree-family-named

(defun ddm-binding () ;; reclaim when on permanent individuals?
  (ddm-ed "objects/model/bindings/structure.lisp")
  (ddm-ed "objects/model/bindings/object2.lisp")
  (ddm-ed "objects/model/bindings/alloc1.lisp")
  (ddm-ed "objects/model/bindings/make2.lisp")
  (ddm-ed "objects/model/bindings/hooks.lisp")
  (ddm-ed "objects/model/bindings/resource.lisp"))


; uniform-scandal
;(ddm-ed "analysers/psp/patterns/traces.lisp")

;; Is there a version of supertype checking that
;; doesn't use the cache ???
; itypep  indiv-typep  category-inherits-type?
; super-categories-of1

;; Set up actions associated with binding
; (ddm-ed "objects/model/bindings/hooks.lisp")

;; Clean up the display at the end of the load, document the globals
; (ddm-ed "interface/grammar/postprocessing.lisp")

;; Walk the model and such
; (ddm-ed "interface/grammar/printing.lisp")

;  (ddm-ed "objects/model/tree-families/rdata1.lisp")

;  (ddm-ed "objects/model/tree-families/driver2.lisp")
;; Works on the rdata of category definitions to instantiate the schema
;; of the ETFs in their mappings to make rules. 
;;    make-rules-for-rdata  instantiate-rule-schema 

;  (ddm-ed "objects/model/tree-families/subrs3.lisp")


(defun ddm-shortcuts ()
  (ddm-ed "grammar/rules/tree-families/shortcut-master2.lisp")
  (ddm-ed "grammar/rules/tree-families/shortcut-expansion.lisp")
  (ddm-ed "grammar/rules/tree-families/shortcut-mechanics.lisp")
  (ddm-ed "grammar/rules/tree-families/families1.lisp")
  (ddm-ed "grammar/rules/tree-families/shortcuts1.lisp")
  (ddm-ed "grammar/rules/tree-families/families.lisp")
  (ddm-ed "grammar/rules/syntax/subcategorization.lisp"))
; (ddm-ed "grammar/model/core/qualities/attribute.lisp")
; (ddm-ed "grammar/model/sl/waypoints/attributes.lisp") ; ex.


(defun ddm-tree-families ()
  (ddm-ed "grammar/rules/tree-families/of.lisp")
  (ddm-ed "grammar/rules/tree-families/np-adjuncts.lisp")
  (ddm-ed "grammar/rules/tree-families/vp-adjuncts.lisp")
  (ddm-ed "grammar/rules/tree-families/verbs-taking-pps.lisp")
  (ddm-ed "grammar/rules/tree-families/that-comp.lisp")
  (ddm-ed "grammar/rules/tree-families/transitive.lisp"))


(defun ddm-grammar ()
  (ddm-ed "init/versons/v4.0/loaders/grammar.lisp")
  (ddm-ed "grammar/rules/tree-families/morphology1.lisp") ;; word rules
  (ddm-ed "grammar/rules/syntax/categories.lisp") ;; and morph tables
  (ddm-ed "grammar/rules/syntax/articles.lisp")
  (ddm-ed "grammar/rules/syntax/be.lisp")
  (ddm-ed "grammar/rules/syntax/prepositions.lisp")
  (ddm-ed "grammar/model/dossiers/modifiers.lisp")
  (ddm-ed "grammar/rules/DA/sentence-fragments.lisp")
  (ddm-ed "grammar/rules/syntax/syntactic-rules.lisp")
  (ddm-ed "grammar/rules/syntax/syntax-functions.lisp")
  (ddm-ed "grammar/rules/syntax/subject-relatives.lisp")
  (ddm-ed "grammar/rules/syntax/conjunction8.lisp")
  (ddm-ed "grammar/rules/syntax/possessive.lisp"))

; (ddm-ed "objects/chart/edge-vectors/tuck.lisp")
; (ddm-ed "objects/chart/edge-vectors/peek.lisp")

(defun ddm-anaphora ()  ;;doc -- note on anaphora
  (ddm-ed "analyzers/CA/anaphora3.lisp")
  (ddm-ed "grammar/rules/CA/defNP2.lisp")
  (ddm-ed "grammar/rules/situation/text-structure.lisp")
  (ddm-ed "grammar/model/core/pronouns/object1.lisp")
  (ddm-ed "grammar/model/core/pronouns/cases1.lisp")
  (ddm-ed "grammar/model/core/pronouns/ref4.lisp")
  (ddm-ed "grammar/rules/syntax/syntax-functions.lisp")
  (ddm-ed "grammar/rules/syntax/articles.lisp")
  (ddm-ed "grammar/rules/words/pronouns.lisp")
  (ddm-ed "objects/traces/pronouns.lisp")
  (ddm-ed "objects/traces/discourse.lisp"))
; (trace-pronouns)  (trace-discourse-structure)

(defun ddm-method-mess ()
  (ddm-ed "objects/model/categories/clos-backing.lisp")
  (ddm-ed "analyzers/psp/referent/ref-method.lisp")
  (ddm-ed "grammar/rules/tree-families/adverbs.lisp")
  (ddm-ed "grammar/rules/tree-families/adjective-phrases.lisp")
  (ddm-ed "grammar/rules/syntax/adjectives.lisp")
  (ddm-ed "grammar/rules/situation/rules.lisp"))
  

;; promulgate being able to abort edges and form-form
;; updates to all edge creators
(defun ddm-edge-makers ()
  (ddm-ed "analyzers/psp/edges/binary-explicit-all-keys2.lisp")
  (ddm-ed "analyzers/psp/edges/binary-explicit2.lisp")
  (ddm-ed "analyzers/psp/edges/binary1.lisp")
  (ddm-ed "analyzers/psp/edges/cs2.lisp")
  (ddm-ed "analyzers/psp/edges/initial-new1.lisp")
  (ddm-ed "analyzers/psp/edges/looking-under.lisp")
  (ddm-ed "analyzers/psp/edges/long-scan1.lisp")
  (ddm-ed "analyzers/psp/edges/polyw1.lisp")
  (ddm-ed "analyzers/psp/edges/single-new2.lisp")
  (ddm-ed "analyzers/psp/edges/unary-driver3.lisp")
  (ddm-ed "analyzers/psp/edges/unkown.lisp"))


(defun ddm-regression-jig ()
  (ddm-ed "objects/doc/sentence-corpora.lisp")
  (ddm-ed "grammar/tests/citations/code/treetop-records.lisp"))
#|  4/18/15  -- comparing to January
? (compare-to-snapshot 'dec-test)
Better: (57 56 55 54 53 50 49 48 46 45 42 41 39 35 34 28 26 25 24 23 22 18 17 13 12 11 10 9 8 7 6 3 2)
Worse: (52 51 29 14)
? (compare-to-snapshot 'dry-run)
Better: (42 39 38 36 34 30 29 25 23 21 19 18 16 15 14 10 9 8 7 5 4 3)
Worse: (28 13 6 2 1)

|#
(defun ddm-load-corpora ()
  (ddm-load "grammar/model/sl/biology/cureRAS/December-text-passages.lisp")
  (ddm-load "grammar/model/sl/biology/cureRAS/January Dry Run passages.lisp")
  (ddm-load "grammar/model/sl/biology/cureRAS/erk-translocation.lisp")
  (ddm-load "grammar/model/sl/biology/cureRAS/aspp2-whole.lisp")
  (ddm-load "interface/R3-eval/overnight-sents.lisp")
  (ddm-load "grammar/model/sl/biology/cureRAS/load-test-sents.lisp"))

(defun ddm-ed-corpora ()
  (ddm-ed "grammar/model/sl/biology/cureRAS/December-text-passages.lisp")
  (ddm-ed "grammar/model/sl/biology/cureRAS/January Dry Run passages.lisp")
  (ddm-ed "grammar/model/sl/biology/cureRAS/erk-translocation.lisp")
  (ddm-ed "grammar/model/sl/biology/cureRAS/aspp2-whole.lisp")
  (ddm-ed "interface/R3-eval/overnight-sents.lisp"))

;;--- 1/6/14
; The short cut realization handler, decode-realization-parameter-list
; does the wrong thing (redundant thing) when there are multiple etf.
; It only has to apply the word rules once, and then apply the rule
; schema for each of the etf.  That will call for refactoring the
; downstream applier:  apply-rdata-mappings

; (bio-setting)  //// needs many more switches set. 
; (f "/Users/ddm/sift/nlp/corpus/biology/Paul-test-cases.txt")
; (f "/Users/ddm/sift/nlp/corpus/biology/Denver_9-4-14.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/darpa/August test cases/processed/PMC3437993.testcase.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/darpa/August test cases/processed/PMC3515079.testcase.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/darpa/August test cases/processed/PMC3651738.testcase.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/darpa/Dec14-TestMaterials/DeepTest/training-passages.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/all passages combinded.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/passage 1.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/passage 2.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/passage 3.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/paper2 passage 1.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/paper2 passage 2.txt")
; (f "/Users/ddm/ws/R3/ws/Mitre December texts/paper2 passage 3.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/darpa/January5-TestMaterials/test-passages.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/darpa/January22-TestMaterials/passage.txt")
; (f "/Users/ddm/ws/R3/r3/trunk/corpus/fontana-good-for-kappa.txt")

; #13 (p "BRAF is inactive in NRAS mutant cells.")
; #13 (p "NRAS or CRAF depletion by RNA interference.")


#| 10/9/14 noun brackets are being added to word::single-quote
(ddm-ed "grammar/rules/words/punctation-bracketing.lisp")
(br-off)
(brackets-on (punctuation-named #\'))
(assign-bracket single-quote ].phrase) 
  but these will interact with the
  use of ' in possessives and contractions
  adjudicate-after-scan-pattern-has-succeeded (trace-ns-sequences)
(p "in the ‘off’ state") 
|#

(defun ddm-edge-mechanics ()
  (ddm-ed "objects/chart/edge-vectors/object2.lisp")
  (ddm-ed "objects/chart/edge-vectors/vectors2.lisp") ;; has knit routine
  (ddm-ed "objects/chart/edges/object3.lisp")
  (ddm-ed "objects/chart/positions/positions1.lisp"))


(defun ddm-vg-elevation ()
  (ddm-ed "grammar/rules/syntax/categories.lisp")
  (ddm-ed "analyzers/SDM&P/scan1.lisp")
  (ddm-ed "grammar/rules/SDM&P/create-categories.lisp"))

(defun ddm-subtyping ()
  (ddm-ed "objects/model/lattice-points/specialize.lisp")
  (ddm-ed "objects/model/lattice-points/structure1.lisp")
  (ddm-ed "objects/model/categories/structure.lisp"))

(defun ddm-ontology ()
  (ddm-ed "grammar/model/core/kinds/upper-model.lisp") ;; top & misc.
  (ddm-ed "grammar/model/core/kinds/processes.lisp")
  (ddm-ed "grammar/model/core/kinds/things.lisp"))

(defun ddm-location ()
  (ddm-ed "grammar/model/core/places/moving.lisp")
  (ddm-ed "grammar/model/core/places/paths.lisp") ;; on-path marker cat.
  (ddm-ed "grammar/model/core/places/configurations.lisp")
  (ddm-ed "grammar/model/core/places/rules2.lisp") ;; in-country commented out
  (ddm-ed "grammar/model/core/places/direction-rules.lisp")) ;; "the" literal



;; 10/14,19/14
(defun ddm-word-lookup ()
  (ddm-ed "objects/chart/words/lookup/new-words4.lisp")
  (ddm-ed "grammar/rules/syntax/affix-rules1.lisp")
  (ddm-ed "grammar/rules/brackets/comlex-unpacking.lisp")
  (ddm-ed "grammar/rules/words/one-offs/comlex-def-forms.lisp")
  (ddm-ed "objects/traces/tokenizer.lisp"))


; 1st  (list-da-actions) ;; from Grok era to hack titles and odd things
(defun ddm-da-files ()
  (ddm-ed "objects/rules/DA/object.lisp") ;; da-rule-named
  (ddm-ed "objects/rules/DA/define.lisp") ;; define-da-rule
  (ddm-ed "objects/rules/DA/decode-patterns.lisp")
  (ddm-ed "analyzers/DA/index.lisp") ;; (trie-for-1st-item tt)
  (ddm-ed "drivers/DA/setup-action.lisp")
  (ddm-ed "drivers/DA/action-globals.lisp")
  (ddm-ed "drivers/DA/fsa-globals.lisp")
  (ddm-ed "drivers/DA/dispatch1.lisp") ;; standalone-da-action
  (ddm-ed "drivers/DA/driver1.lisp")
  (ddm-ed "drivers/DA/fsa.lisp")
  (ddm-ed "grammar/rules/DA/aux+morph.lisp")
  (ddm-ed "grammar/model/core/titles/of-titles.lisp"))

; 2d   (list-ca-actions) ;; very old heuristic searches
(defun ddm-ca-actions ()
  (ddm-ed "grammar/rules/CA/stranded-VP1.lisp")
  (ddm-ed "drivers/forest/CA/CA4.lisp")
  (ddm-ed "analyzers/CA/actions.lisp")
  (ddm-ed "analyzers/CA/search2.lisp")
  (ddm-ed "analyzers/CA/scanners1.lisp"));; (comma-just-to-its-left edge)

; 3d   (list-generic-treetop-actions) ;; for stranded "of", "and", hyphen
(defun ddm-generic-tt-actions ()
  (ddm-ed "drivers/forest/actions1.lisp"))

(defun ddm-patterns ()
  (ddm-ed "objects/rules/scan-patterns/start.lisp") ;; empty
  (ddm-ed "objects/rules/scan-patterns/forms.lisp")
  (ddm-ed "objects/rules/scan-patterns/pattern-elements.lisp")
  (ddm-ed "objects/rules/scan-patterns/transitions.lisp")
  (ddm-ed "objects/rules/scan-patterns/patterns.lisp")
  (ddm-ed "objects/rules/scan-patterns/states.lisp")
  (ddm-ed "analyzers/psp/patterns/take-transitions.lisp")
  (ddm-ed "analyzers/psp/patterns/follow-out.lisp")
  (ddm-ed "analyzers/psp/patterns/accept.lisp")
  (ddm-ed "analyzers/psp/patterns/driver.lisp")
  (ddm-ed "analyzers/psp/patterns/initiate-pattern-scan.lisp")
  (ddm-ed "analyzers/psp/patterns/accept.lisp")
  (ddm-ed "analyzers/psp/patterns/traces.lisp"))


(defun ddm-original-forest ()
  (ddm-ed "drivers/chart/psp/PPTT8.lisp")
  (ddm-ed "drivers/chart/psp/trigger5.lisp")
  (ddm-ed "drivers/forest/trap2.lisp"))

(defun ddm-character-level ()
  (ddm-ed "analyzers/char-level/testing1.lisp")
  (ddm-ed "analyzers/char-level/state2.lisp")
  (ddm-ed "analyzers/char-level/setup-file3.lisp"))


(defun load-ddm-ws ()
  (ddm-ed "init/workspaces/reference-points.lisp")
  (ddm-ed "init/workspaces/traces.lisp")
  

  (ddm-ed "init/versions/v4.0/workspace/abbreviations.lisp")
  (ddm-ed "init/workspaces/Biology-workspace.lisp"))
; (ed "/Users/ddm/ws/Sparser local/workspaces/fire.lisp")


;;;------------------

;;--- Peter Clark's string function utilities
; (ed "/Users/ddm/ws/Vulcan/HaloEval/haloevaldata/scripts/logparser/km/strings.lisp")
; (bel::read-model )

(defun ddm-corpus-location (in-list out-file)
  (declare (ignore in-list out-file))
  ;; Note the pathname is given in ancient Mac syntax. 
  (setq cl-user::location-of-text-corpora
        "Users:ddm:sift:nlp:corpus:"))

(defun ddm-ed (string)
  #-:sbcl
  (ed (cl-user::sparser-sourcefile string))
  #+:sbcl
  (print `(**** can't call ed from SBCL yet)))

(defun ddm-load (string)
  (load (sparser-sourcefile string)))

(defun sparser-doc-ed (string)
  (ed (sparser-file "Sparser/documentation/" string)))

(defun draft-doc-ed (string)
  (ed (concatenate 'string
        "~/nlp/Sparser/documentation/notes-in-preparation/"
        string)))

(defun ddm-r3-notes (string)
  (ed (concatenate 'string
        "~/ws/R3/r3/trunk/notes/" string)))

(defun ddm-ws-ed (string)
  (ed (concatenate 'string
         "~/ws/Sparser local/ws/" string)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;--- 2d work over the result
; (ddm-ed "grammar/rules/words/one-offs/obo-reader.lisp")
; (read-obo-term-file "/Users/ddm/ws/R3/ws/obo-terms.lisp")

; (load "/Users/ddm/ws/R3/r3/trunk/code/bel-interpreter/load.lisp")

#|
wget --output-document=${PMCID}.nxml 'http://www.pubmedcentral.nih.gov/oai/oai.cgi?verb=GetRecord\&identifier=oai:pubmedcentral.nih.gov:${PMCID}&metadataPrefix=pmc'

wget --output-document=3537887.nxml 'http://www.pubmedcentral.nih.gov/oai/oai.cgi?verb=GetRecord\&identifier=oai:pubmedcentral.nih.gov:${PMCID}&metadataPrefix=pmc'

3847091
|#

